<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>基础框架平台服务前端预览中心-单表服务</title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="bootstrap/css/bootstrap-table.css" rel="stylesheet" />
    <link href="bootstrap/css/bootstrap-table-fixed-columns.css" rel="stylesheet" />
    <link href="bootstrap/css/bootstrap-editable.css" rel="stylesheet" />
    <link href="bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="css/docs.css" rel="stylesheet" />
    <link href="css/pygments-manni.css" rel="stylesheet" />
</head>
<body style="background-color: #F1F3FA;">
<nav class="navbar navbar-default" style="margin-top:5px; margin-bottom:5px;">
    <div class="container-fluid">
        <div class="navbar-header" style="font-size:16px; padding-top:8px;">
            <span style="font-size: 23px; border: solid 1px #DDDDDD; padding:0px 5px; margin-right:25px; float:left;">单表服务数据加密</span>
        </div>
    </div>
</nav>
<div class="panel panel-default">
    <div class="panel-heading">
        加密后数据
    </div>
    <div id="jmcontent" class="panel-body">

    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">
        <span>解密后数据</span>
        <span style="margin-left: 20px;"><button id="btn_jm" type="button" class="btn btn-primary">解密</button></span>
    </div>
    <div id="jiemcontent" class="panel-body">

    </div>
</div>


<script src="js/jquery-1.10.2.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="bootstrap/js/bootstrap-table.min.js"></script>
<script src="bootstrap/js/bootstrap-table-zh-CN.js"></script>
<script src="bootstrap/js/bootbox.min.js"></script>
<script src="bootstrap/js/bootstrap-datetimepicker.min.js"></script>
<script src="bootstrap/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="js/services/serviceConfig.js"></script>
<script src="js/docs.js"></script>
<script src="js/crypto-js.min.js"></script>
<script type="text/javascript">
$(function () {

    //查询加密数据
    $.ajax({
        type : 'GET',//请求方式GET
        url : '/business/singleServer/querySingleTBDES' ,
        async : false,
        data :{serviceID:serviceId,pageNO:'1',pageSize:'10',conQuery:null},
        success : function(data) {
            //返回data结果，Json格式的数据{"result":"查询结果状态码(0成功,1失败)","message":"查询结果信息","data":{"total":"总条数","rows":[{数据集合}]}}
            $("#jmcontent").html(JSON.stringify(data));
        }
    });

    //查询解密数据
    $("#btn_jm").click(function () {
        $.ajax({
            type : 'GET',//请求方式GET
            url : '/business/singleServer/querySingleTBDES' ,
            async : false,
            data :{serviceID:serviceId,pageNO:'1',pageSize:'10',conQuery:null},
            success : function(data) {
                //返回data结果，Json格式的数据{"result":"查询结果状态码(0成功,1失败)","message":"查询结果信息","data":{"total":"总条数","rows":[{数据集合}]}}
                var resdata = Decrypt('elitel2019basefr',data.data);
                $("#jiemcontent").html(JSON.stringify(resdata));
            }
        });

    });

    //解密
    function Decrypt(keyStr,word){
        var key = CryptoJS.enc.Utf8.parse(keyStr);
        var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    }



});
</script>
</body>
</html>
